package com.clone.surpassli.clone_cloudreader.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.OvershootInterpolator;

import com.clone.surpassli.clone_cloudreader.R;
import com.clone.surpassli.clone_cloudreader.base.baseadapter.BaseRecyclerViewAdapter;
import com.clone.surpassli.clone_cloudreader.base.baseadapter.BaseRecyclerViewHolder;
import com.clone.surpassli.clone_cloudreader.bean.moviechild.SubjectsBean;
import com.clone.surpassli.clone_cloudreader.databinding.ItemOneBinding;
import com.clone.surpassli.clone_cloudreader.utils.CommonUtils;
import com.clone.surpassli.clone_cloudreader.utils.PerfectClickListener;
import com.nineoldandroids.view.ViewHelper;
import com.nineoldandroids.view.ViewPropertyAnimator;

/**
 * Created by SurpassLi on 2017/10/10.
 * OneAdapter 电影介绍页的Adapter
 */

public class OneAdapter extends BaseRecyclerViewAdapter<SubjectsBean>{
    private Activity activity;

    public OneAdapter(Activity activity){
        this.activity = activity;
    }

    @Override
    public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(parent, R.layout.item_one);
    }

    private class ViewHolder extends BaseRecyclerViewHolder<SubjectsBean,ItemOneBinding> {
        public ViewHolder(ViewGroup viewGroup, int layoutId) {
            super(viewGroup, layoutId);
        }

        @Override
        public void onBindViewHolder(SubjectsBean object, int position) {
            if (object!=null) {
                binding.setSubjectsBean(object);
                // 图片
//                ImgLoadUtil.displayEspImage(positionData.getImages().getLarge(), binding.ivOnePhoto,0);
                // 导演
//                binding.tvOneDirectors.setText(StringFormatUtil.formatName(positionData.getDirectors()));
                // 主演
//                binding.tvOneCasts.setText(StringFormatUtil.formatName(positionData.getCasts()));
                // 类型
//                binding.tvOneGenres.setText("类型：" + StringFormatUtil.formatGenres(positionData.getGenres()));
                // 评分
//                binding.tvOneRatingRate.setText("评分：" + String.valueOf(positionData.getRating().getAverage()));
                // 分割线颜色
                binding.viewColor.setBackgroundColor(CommonUtils.randomColor());

                ViewHelper.setScaleX(itemView,0.8f);
                ViewHelper.setScaleY(itemView,0.8f);
                ViewPropertyAnimator.animate(itemView).scaleX(1).setDuration(350).setInterpolator(new OvershootInterpolator()).start();
                ViewPropertyAnimator.animate(itemView).scaleY(1).setDuration(350).setInterpolator(new OvershootInterpolator()).start();
                binding.llItem.setOnClickListener(new PerfectClickListener() {
                    @Override
                    protected void onNoDoubleClick(View v) {

                    }
                });
            }
        }
    }
}
